package com.home.duy.code.Renderer;

import java.awt.Color;
import java.awt.Component;
import java.text.NumberFormat;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import com.home.Common.Resources_Duy;

public class CurrencyTableCellRenderer extends DefaultTableCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		NumberFormat formatFloat = NumberFormat.getCurrencyInstance();
		formatFloat.setMinimumFractionDigits(0);
		this.setText(formatFloat.format(value));
		setForeground(Resources_Duy.COLOR_BG_TITLE_IMAGE);
		if (isSelected) {
			setBackground(new Color(75, 105, 138));
			setForeground(Color.WHITE);
		} else {
			
			if (row % 2 == 0) {
				setBackground(new Color(242, 242, 242));
			} else {
				setBackground(Color.WHITE);
			}
		}
		return this;
	}

}
